package com.dtzhejiang.social.supervision.risk.engine.common.domain.bo;

import com.dtzhejiang.social.supervision.risk.engine.common.domain.po.PageEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;


@Data
public class PageInfo<T> implements Serializable {
    private static final long serialVersionUID = -6011307790633488215L;
    /**
     * 当前页码
     */
    @ApiModelProperty(value = "当前页码",example="10")
    private Integer pageNo;
    /**
     * 每页数量
     */
    @ApiModelProperty(value = "每页数量",example="10")
    private Integer pageSize;
    /**
     * 当前页数量
     */
    @ApiModelProperty(value = "当前页数量",example="10")
    private Integer currentPageSize;

    /**
     * 总记录条数
     */
    @ApiModelProperty(value = "总记录条数",example="10")
    private Integer totalCount;

    /**
     * 总记页数
     */
    @ApiModelProperty(value = "总记页数",example="10")
    private Integer totalPage;

    /**
     * 数据内容
     */
    private List<T> records;


    @SuppressWarnings("unchecked")
    public static <T> PageInfo<T> getInstance() {
        PageInfo pageInfo = new PageInfo();
        pageInfo.setPageNo(PageEntity.ONE);
        pageInfo.setPageSize(PageEntity.DEFAULT_PAGE_SIZE);
        pageInfo.setCurrentPageSize(0);
        pageInfo.setTotalCount(0);
        pageInfo.setTotalPage(0);
        pageInfo.setRecords(Collections.emptyList());
        return pageInfo;
    }

    public PageInfo() {
        this.pageNo = PageEntity.ONE;
        this.pageSize = PageEntity.DEFAULT_PAGE_SIZE;
        this.currentPageSize = 0;
        this.totalCount = 0;
        this.totalPage = 0;
        this.records = Collections.emptyList();
    }

}